<?php
session_start();
require_once('../firelynx.php');



$response = new fily_AjaxResponse();

$id = $_REQUEST['id'];

list($url, $action) =   explode("#", $response->getTriggerControl()->attributes->get("href"));
// get the action from the href
// url contains the full url if IE6 was used
if($action=="cancel" || $action=="save"){
    if( $action=="save"){
        // save values into session
        $_SESSION["data"][$id][0] = $_REQUEST['column1'];
        $_SESSION["data"][$id][1] = $_REQUEST['column2'];
        $_SESSION["data"][$id][2] = $_REQUEST['column3'];
    }
    // show normal row
    $rowData = $_SESSION["data"][$id];
    $controlList = fily_XMLConverter::convertFile("normalRow.xml", $response);
    $response->addUpdateTrigger($controlList->getControlBySid('link'),'click');
    // bind values
    $controlList->getControlBySid('column1')->setText($rowData[0]);
    $controlList->getControlBySid('column2')->setText($rowData[1]);
    $controlList->getControlBySid('column3')->setText($rowData[2]);
}
else {
    // show edit row
    $controlList =  fily_XMLConverter::convertFile('editRow.xml', $response);
    $cell =$controlList->getControlBySid('save')->getParent();
    $response->addUpdateTrigger($controlList->getControlBySid('save'),'click');
    $response->addUpdateTrigger($controlList->getControlBySid('cancel'),'click');
    $rowData = $_SESSION["data"][$id];
    // bind values
    $controlList->getControlBySid('column1')->setValue($rowData[0]);
    $controlList->getControlBySid('column2')->setValue($rowData[1]);
    $controlList->getControlBySid('column3')->setValue($rowData[2]);
}
 echo $response;
?>
